package com.richapp.launcher.database.system.mode;

import com.j256.ormlite.field.DatabaseField;
import com.j256.ormlite.table.DatabaseTable;

@DatabaseTable(tableName = "conditioinsTime")
public class ConditionTimeModel {

	@DatabaseField(generatedId = true)
	private int id;
	
	@DatabaseField(columnName = "sceneName")
	private String sceneName;   //情景名称
	
	@DatabaseField(columnName = "conditionType")
	private int conditionType;	//主条件类型
	
	@DatabaseField(columnName = "conditionSubType")
	private int conditionSubType;	//子条件类型
	
	//aging 时效
	@DatabaseField(columnName = "agingStartTime")
	private long agingStartTime;	//开始时间
	@DatabaseField(columnName = "agingStopTime")
	private long agingStopTime;		//结束时间
	
	//delay 延时
	@DatabaseField(columnName = "delayStartTime")
	private long delayStartTime;	//开始时间
	@DatabaseField(columnName = "delayDelayTime")
	private long delayDelayTime;	//时长
	
	//dimming 定时
	@DatabaseField(columnName = "dimingModelType")
	private int dimingModelType;	//定时模式:每天，每周，每月
	
	@DatabaseField(columnName = "hours")
	private int hours;	//时
	@DatabaseField(columnName = "minutes")
	private int minutes; //分
	@DatabaseField(columnName = "seconds")
	private int seconds; //秒
	
	@DatabaseField(columnName = "weekDays")
	private String weekDays;	//每周中的星期N  1|2|3|4
	@DatabaseField(columnName = "monthDays")
	private String monthDays;	//每月中的N号 1|5|20|30
	
	
	public ConditionTimeModel() {
		
	}


	public int getId() {
		return id;
	}


	public void setId(int id) {
		this.id = id;
	}


	public String getSceneName() {
		return sceneName;
	}


	public void setSceneName(String sceneName) {
		this.sceneName = sceneName;
	}


	public int getConditionType() {
		return conditionType;
	}


	public void setConditionType(int conditionType) {
		this.conditionType = conditionType;
	}


	public int getConditionSubType() {
		return conditionSubType;
	}


	public void setConditionSubType(int conditionSubType) {
		this.conditionSubType = conditionSubType;
	}


	public long getAgingStartTime() {
		return agingStartTime;
	}


	public void setAgingStartTime(long agingStartTime) {
		this.agingStartTime = agingStartTime;
	}


	public long getAgingStopTime() {
		return agingStopTime;
	}


	public void setAgingStopTime(long agingStopTime) {
		this.agingStopTime = agingStopTime;
	}


	public long getDelayStartTime() {
		return delayStartTime;
	}


	public void setDelayStartTime(long delayStartTime) {
		this.delayStartTime = delayStartTime;
	}


	public long getDelayDelayTime() {
		return delayDelayTime;
	}


	public void setDelayDelayTime(long delayDelayTime) {
		this.delayDelayTime = delayDelayTime;
	}

	public int getDimingModelType() {
		return dimingModelType;
	}


	public void setDimingModelType(int dimingModelType) {
		this.dimingModelType = dimingModelType;
	}


	public int getHours() {
		return hours;
	}


	public void setHours(int hours) {
		this.hours = hours;
	}


	public int getMinutes() {
		return minutes;
	}


	public void setMinutes(int minutes) {
		this.minutes = minutes;
	}


	public int getSeconds() {
		return seconds;
	}


	public void setSeconds(int seconds) {
		this.seconds = seconds;
	}


	public String getWeekDays() {
		return weekDays;
	}
	
	public int[] getWeekDaysArray() {
		return getStringsToIntArray(weekDays);
	}

	public void setWeekDays(String weekDays) {
		this.weekDays = weekDays;
	}


	public String getMonthDays() {
		return monthDays;
	}
	
	public int[] getMonthDaysArray() {
		return getStringsToIntArray(monthDays);
	}


	public void setMonthDays(String monthDays) {
		this.monthDays = monthDays;
	}
	
	private int[] getStringsToIntArray(String times){
		if(times != null){
			String[] strs = times.split("\\|");
			if(strs.length > 0 ){
				int[] result = new int[strs.length];
				for(int i = 0 ; i < result.length ; i++){
					result[i] = Integer.parseInt(strs[i]);
				}
				return result;
			}
		}
		return null;
	}

}
